package com.jinyi.base.mvp;

import com.jinyi.base.base.BaseActivity;


/**
 * @Author：wwdeng
 * @Time：2024/4/14 18:18
 * <pre>
 *
 * </pre>
 */
public abstract class BaseMvpActivity<V extends IBaseView, P extends BasePresenter> extends BaseActivity{
    protected P presenter;

    /**
     * 初始化Presenter
     */
    public void initPresenter() {
        if (presenter == null){
            presenter = createPresenter();
            presenter.attachView((V) this);
        }
    }

    /**
     * 创建Presenter
     *
     * @return
     */
    protected abstract P createPresenter();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.detachView();
    }
}